/****************************************************************************
*                                                                           *
*  Lister -- by Keith Rollin                                                *
*                                                                           *
*                                                                           *
*   19-MAR-88   v1.0B1  Kaar    New Today                                   *
*   20-MAR-88   v1.0B2  Kaar    Fixed bug where About zooming would draw    *
*                               with a grey outline. Fixed mysterious       *
*                               disabling of About button.                  *
*   28-MAR-88   v1.0B3  Kaar    Added support for PicComments. Added        *
*                               Command codes for Print and File Buttons.   *
*   10-MAY-88   v1.0B4  Kaar    Allocated 2 pages for print manager (like I *
*                               should have). This fixed a problem with the *
*                               Font Manager not working.                   *
*   11-MAY-88   v1.0B5  Kaar    Added more support for different fonts when *
*                               using postscript. Tried to fix problems     *
*                               Command occured when changing types of      *
*                               printers, but I failed.                     *
*   26-JUN-88   v1.0B6  Kaar    Put the whole program into Standard Format. *
*                               Added comments and error checking. Added    *
*                               code to preserve settings when we change    *
*                               printers. Worked around ChooseFont bug.     *
*   27-JUN-88   v1.0B7  Kaar    Cleaned up the way the Percent Reduction    *
*                               box was handled. Changed the way I set the  *
*                               font in the LaserWriter. Changed the key    *
*                               equivalent of Quit from <return> to Cmd-Q.  *
*    3-JUL-88   v1.0B8  Kaar    Finally found the source of a couple of     *
*                               Mysterious Bugs. One caused the font in the *
*                               main window to change, and the other caused *
*                               the appearance of printing, when nothing    *
*                               really happened. Both of these were due to  *
*                               the Print Manager short-circuiting some     *
*                               routines when errors occurred when it       *
*                               shouldn't have. They've been worked around  *
*                               and only occur on System Disk 3.2; they've  *
*                               been fixed with System Disk 4.0             *
*   1-SEP-88    v1.0    Kaar    First release.                              *
*   7-DEC-88    v1.0.1  Mensch  Took out Desktop call.                      *
*                                                                           *
*                                                                           *
****************************************************************************/

/*********************************************************************
*                                                                    *
*             Apple IIGS Source Code Sampler, Volume I               *
*                                                                    *
*             Copyright (c) Apple Computer, Inc. 1988                *
*                       All Rights Reserved                          *
*                                                                    *
*            Written by Apple II Developer Tech Support              *
*                                                                    *
*                                                                    *
*                                                                    *
*  ----------------------------------------------------------------  *
*                                                                    *
*     This program and its derivatives are licensed only for         *
*     use on Apple computers.                                        *
*                                                                    *
*     Works based on this program must contain and                   *
*     conspicuously display this notice.                             *
*                                                                    *
*     This software is provided for your evaluation and to           *
*     assist you in developing software for the Apple IIGS           *
*     computer.                                                      *
*                                                                    *
*     DISCLAIMER OF WARRANTY                                         *
*                                                                    *
*     THE SOFTWARE IS PROVIDED "AS IS" WITHOUT                       *
*     WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,               *
*     WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS             *
*     FOR ANY PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO             *
*     THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH            *
*     YOU.  SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU (AND            *
*     NOT APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE)               *
*     ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING,             *
*     REPAIR OR CORRECTION.                                          *
*                                                                    *
*     Apple does not warrant that the functions                      *
*     contained in the Software will meet your requirements          *
*     or that the operation of the Software will be                  *
*     uninterrupted or error free or that defects in the             *
*     Software will be corrected.                                    *
*                                                                    *
*     SOME STATES DO NOT ALLOW THE EXCLUSION                         *
*     OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY              *
*     NOT APPLY TO YOU.  THIS WARRANTY GIVES YOU SPECIFIC            *
*     LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS                *
*     WHICH VARY FROM STATE TO STATE.                                *
*                                                                    *
*                                                                    *
*********************************************************************/



#include "Lister.h"




/* ************************************************************************* */
/*                                                                           */
/* Standard Global data here                                                 */
/*                                                                           */
/* ************************************************************************* */

char TitleString[]  = "\Text File Lister";
char AutString[]    = "\pBy Keith Rollin (c)1988 Apple Computer";
char VersString[]   = "\pVersion: 1.0";

extern int _toolErr;

int MyID;
#define ThisMode mode640            /* Init mode = 640                      */
#define ScreenWidth 640             /* Used to init the Event Manager       */
#define MAXSCAN    320              /* Used to init QuickDraw. NOTE: As per */
                                    /* the Printing Manager chapter, this   */
                                    /* value is twice as large as you would */
                                    /* normally expect it to be. This is to */
                                    /* take into account double resolution  */
                                    /* when printing in Better Text mode on */
                                    /* the ImageWriter.                     */

int ToolTable[] = {11,
                14, 0x0100,         /* Window Manager   */
                15, 0x0100,         /* Menu Manager     */
                16, 0x0100,         /* Control Mnager   */
                20, 0x0100,         /* Line Edit        */
                21, 0x0100,         /* Dialog Manager   */
                22, 0x0100,         /* Scrap Manager    */
                18, 0x0100,         /* QD Aux           */
                19, 0x0100,         /* Print Manager    */
                23, 0x0100,         /* Standard File    */
                27, 0x0100,         /* Font Manager     */
                28, 0x0100          /* List manager     */
                };


/* ************************************************************************* */
/*                                                                           */
/* Application specific data appears here                                    */
/*                                                                           */
/* ************************************************************************* */

/* The LaserWriter Driver on System Disk 3.2 supports PicComments, commands */
/* that are included with QDAux pictures and that customize the appearance  */
/* of pictures. The LaserWriter Driver intercepts the routine that handles  */
/* PicComments, and can be commanded to perform special actions that are    */
/* not normally available to QuickDraw. In this case, we are going to use   */
/* a facility to send raw PostScript commands to the LaserWriter driver. We */
/* do this by puttin the LaserWriter driver into 'PostScript Mode' with the */
/* PostScriptBegin PicComment . The we describe HOW we are going to send    */
/* the PostScript text. In this program, we want to send the commands with  */
/* the DrawString and DrawCString commands. We tell the LaserWriter driver  */
/* of our intentions with the TextIsPostScript PicComment. Finally, when we */
/* are done, we issue the PostScriptEnd PicComment to put the LaserWriter   */
/* driver back into normal QuickDraw mode. The definitions below facilitate */
/* all of this.                                                             */

#define PostScriptBegin     190
#define TextIsPostScript    194
#define PostScriptEnd       191

/* Forward declarations of some routines */

extern void SetReduction();
extern void SetOrientation();
extern void SetVSizing();
extern void CreatePSSetFontCommand();
extern pascal void DrawUserItem();

char        **y,*z;         /* ZPHandle and ZPPointer                       */
SFReplyRec  myReply;        /* Reply record for SFGetFile                   */
GrafPortPtr myDialog;       /* Dialog box record pointer                    */
PrRecHndl   PrintHndl;      /* Handle to my Print record                    */
int         numCols;        /* Number of columns per page to print          */
int         theReduction;   /* Amount of reduction I'll be doing            */
int         theVSizing;     /* Vertical aspact ratio                        */
LongWord    theFont;        /* The ID of the font to print in               */
boolean     sideways;       /* flag for Landscape or Portrait printing      */
boolean     PostScript;     /* TRUE if printing to PostScript device.       */

int         lineHeight,     /* variables used for page layout when printing */
            maxLines,
            lineTop,
            lineBottom,
            pageNum;
boolean     haveHeader,     /* These too                                    */
            haveFooter;
char        line[255];      /* buffer for current line to print             */
Rect        myPage,         /* used to change the size of page to print to  */
            *myPagePtr;
char        time[20];       /* string to hold the time when printing        */


/* ProDOS records for I/O */

OpenRec     OpenParms       = {0,myReply.fullPathname,0};
NewlineRec  NewlineParms    = {0,0x7f,0x0d};
FileIORec   IOParms         = {0,line,255,0};


/* Record for SFGetFile. It specifies the types of files to display in the  */
/* dialog box. The first byte indicates the number of filetypes we will     */
/* allow to be displayed in the dialog box. The subsequent bytes are the    */
/* filetypes. In this case, we want to read in one of two type: TXT and SRC.*/

byte myTypes[] = {2,4,176};     /* TXT = 4, SRC = 176   */


/* String constants. */
/* The first is used by SFGetFile.                                          */

char prompt[] = "\pLoad what file:";

/* Used to create PostScript commands that position and print the string.   */

char PSMoveStr[] = " moveto\r";
char PSShow1[] = " (";
char PSShow2[] = ") show\r";

/* Used for AlertWindow Dialogs                                             */

char NoMemAlertString[] = "32/Not enough memory to print the file!!!/^#0";

char ErrCanceled[] = "32/Printing was canceled because you pressed \021-./^#0";

char ErrMissingDriver[] = "32/Specified driver not in the DRIVERS \
subdirectory of the SYSTEM subdirectory/^#0";

char ErrPortNotOn[] = "32/Specified port not selected in the Control \
Panel./^#0";

char ErrNoPrintRecord[] = "32/No print record was specified./^#0";

char ErrBadLaserPrep[] = "42/The version of the LaserPrep file in the \
LaserWriter is not compatible with this version of the Print Manager/^#0";

char ErrBadLPFile[] = "42/The version of the LaserPrep file in the DRIVERS \
subdirectory in the SYSTEM subdirectory is not compatible with this verson \
of the Print Manager/^#0";

char ErrPapConnNotOpen[] = "32/Connection couldn't be established with the \
LaserWriter./^#0";

char ErrPapReadWriteErr[] = "32/Read-Write error on the LaserWriter./^#0";

char ErrPntrConFailed[] =  "32/Connection to the printer failed./^#0";

char ErrGeneric[] = "32/Print error $*0 occured!!!/^#0";

char PrintErrNum[] = "xxxx";

Pointer SubStrings[] = {
        PrintErrNum
        };



/* ID numbers of the Dialog items */

#define Quit            22
#define ChFile          3
#define ChPrinter       4
#define ChFont          5
#define PgSetup         6
#define Print           7
#define About           8
#define Portrait        9
#define Landscape       10
#define Header          11
#define Footer          12
#define Columns         13
#define Percent         14
#define ColumnText      15
#define HeaderText      16
#define FooterText      17
#define PercentText     18
#define Borders         19
#define UseBorder       20
#define Title           21


/* These next 2 blocks of data are used for a couple of user items I    */
/* have. I use PPToPort to Blit them onto the screen. You you can click */
/* on them to select whether you want Portrait or Landscape printing.   */

/* Data for Portrait (i.e., upright) icon */

Rect portraitRect  = {0x0000,0x0000,0x0010,0x0020};

char portraitIcon[] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xf0,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xf0,0xff,0xff,0xff,0xff,0xf0,0x0f,0xff,
0xf0,0xff,0xff,0xf0,0x0f,0xf0,0xf0,0xff,
0xf0,0xff,0xff,0x0f,0xf0,0xf0,0x00,0x0f,
0xf0,0xff,0xff,0x0f,0xf0,0xff,0xff,0x0f,
0xf0,0xff,0xff,0xf0,0x0f,0xff,0xff,0x0f,
0xf0,0xff,0xf0,0x0f,0xf0,0x0f,0xff,0x0f,
0xf0,0xff,0x0f,0xff,0xff,0xf0,0xff,0x0f,
0xf0,0xff,0x0f,0x0f,0xf0,0xf0,0xff,0x0f,
0xf0,0xff,0x0f,0x0f,0xf0,0xf0,0xff,0x0f,
0xf0,0xff,0x0f,0x0f,0xf0,0xf0,0xff,0x0f,
0xf0,0xff,0x0f,0x0f,0xf0,0xf0,0xff,0x0f,
0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};

LocInfo portraitLoc = {
            mode640,                            /* portSCB      */
            (Pointer) portraitIcon,             /* PixImagePtr  */
            0x8,                                /* RowBytes     */
            0x0000,0x0000,0x0010,0x0020};       /* BoundsRect   */

/* Data for Landscape (i.e., sideways) icon */

Rect landscapeRect = {0x0000,0x0000,0x0010,0x0020};

char landscapeIcon[] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xf0,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,
0xf0,0xff,0xff,0xff,0xff,0xf0,0xf0,0xff,
0xf0,0xff,0xff,0xff,0xff,0xf0,0x00,0x0f,
0xf0,0xf0,0x00,0x0f,0xff,0xff,0xff,0x0f,
0xf0,0xff,0xff,0xf0,0xff,0xff,0xff,0x0f,
0xf0,0xf0,0x00,0xf0,0xf0,0x0f,0xff,0x0f,
0xf0,0xff,0xff,0xff,0x0f,0xf0,0xff,0x0f,
0xf0,0xff,0xff,0xff,0x0f,0xf0,0xff,0x0f,
0xf0,0xf0,0x00,0xf0,0xf0,0x0f,0xff,0x0f,
0xf0,0xff,0xff,0xf0,0xff,0xff,0xff,0x0f,
0xf0,0xf0,0x00,0x0f,0xff,0xff,0xff,0x0f,
0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};

LocInfo landscapeLoc = {
            0x80,
            (Pointer) landscapeIcon,
            0x8,
            0x0000,0x0000,0x0010,0x0020};


/* Data for edittext items below                                        */

char    columnDText[] = "\p1";
char    percentDText[]= "\p100";


/* These are the Dialog Item definitions. The \021's imbeded in some of */
/* the text items appear as Open-Apples on the Apple IIGS SHR screen.   */

ItemTemplate quitButton =  {
            Quit,                   /* Item ID number                   */
            140,450,154,590,        /* Bounding rectangle               */
            buttonItem,             /* Item type                        */
            "\pQuit   \021Q",       /* Pointer to string for this item  */
            0,                      /* Initial value for the thing      */
            0,                      /* flags for this item              */
            NULL};                  /* Pointer to color table           */

ItemTemplate chFileButton =  {
            ChFile,
            100,10,114,150,
            buttonItem,
            "\pChoose File   \021F",
            0,
            0,
            NULL};

ItemTemplate chPrButton =  {
            ChPrinter,
            120,10,134,150,
            buttonItem,
            "\pChoose Printer",
            0,
            0,
            NULL};

ItemTemplate chFontButton =  {
            ChFont,
            140,10,154,150,
            buttonItem,
            "\pChoose Font",
            0,
            0,
            NULL};

ItemTemplate pgSetupButton =  {
            PgSetup,
            100,450,114,590,
            buttonItem,
            "\pPage Setup",
            0,
            0,
            NULL};

ItemTemplate printButton =  {
            Print,
            120,450,134,590,
            buttonItem,
            "\pPrint   \021P",
            0,
            0,
            NULL};

ItemTemplate aboutButton =  {
            About,
            5,10,19,150,
            buttonItem,
            "\pAbout",
            0,
            0,
            NULL};

ItemTemplate portraitButton =  {
            Portrait,
            5,513,21,545,
            userItem,
            (Pointer) DrawUserItem,
            0,
            0,
            NULL};

ItemTemplate landscapeButton =  {
            Landscape,
            5,558,21,590,
            userItem,
            (Pointer) DrawUserItem,
            0,
            0,
            NULL};

ItemTemplate headerEdit =  {
            Header,
            35,10,50,590,
            editLine,
            "\p@d @t|@l|Page: @p",
            128,                        /* Value = max text to enter */
            0,
            NULL};

ItemTemplate footerEdit =  {
            Footer,
            65,10,80,590,
            editLine,
            NULL,
            128,
            0,
            NULL};

ItemTemplate borderItem =  {
            Borders,
            100,175,154,425,
            userItem,
            (Pointer) DrawUserItem,
            0,
            0,
            NULL};

ItemTemplate borderCheck =  {
            UseBorder,
            85,440,0,0,
            checkItem,
            "\pDon't use borders",
            0,
            0,
            NULL};

ItemTemplate columnEdit =  {
            Columns,
            82,10,97,30,
            editLine,
            NULL,
            1,
            0,
            NULL};

ItemTemplate columnStat =  {
            ColumnText,
            85,40,94,100,
            statText+itemDisable,
            "\pColumns",
            0,
            0,
            NULL};

ItemTemplate headerStat =  {
            HeaderText,
            25,10,34,610,
            statText+itemDisable,
            "\pHeader:    {@D=Date, @T=Time, @L/@S=Lg/Sh File name, \
@P=Pg#, |=Field Divider}",
            0,
            0,
            NULL};

ItemTemplate footerStat =  {
            FooterText,
            55,10,64,110,
            statText+itemDisable,
            "\pFooter:",
            0,
            0,
            NULL};

ItemTemplate percentEdit =  {
            Percent,
            82,125,97,160,
            editLine,
            NULL,
            3,
            0,
            NULL};

ItemTemplate percentStat =  {
            PercentText,
            85,165,94,300,
            statText+itemDisable,
            "\p% of original size",
            0,
            0,
            NULL};

/* This bit of text is, admittedly, very confusing. What it represents is   */
/* text that can be passed to the Dialog Manager for a LongStatText2 item.  */
/* The Dialog Manager will then use LETextBox2 to print it out. All of the  */
/* slash 1's are escape characters used by LETextBox2 to mark embedded      */
/* format characters. For instance, "\1C\5\0" compiles into memory as       */
/* "01 43 05 00" which tells LETextBox2 to set the foreground color to 5.   */

char myTitle[] = "\1C\5\0\1J\1\0\1F\0\0\006\020Lister\1F\0\0\0\0";
ItemTemplate laserLister = {
            Title,
            0,200,20,400,
            longStatText2+itemDisable,
            myTitle,
            sizeof(myTitle) - 1,        /* Value = size of text to print    */
            0,
            NULL};

/* Here is the template that describes the entire dialog box                */
DialogTemplate PrintDialog = {
            30,20,190,620,              /* Size/Position of the window      */
            false,                      /* visible flag (it's invisible)    */
            0,                          /* refcon for my use                */
            &quitButton,                /* list of items in dialog box      */
            &chFileButton,
            &chPrButton,
            &chFontButton,
            &pgSetupButton,
            &printButton,
            &aboutButton,
            &landscapeButton,
            &portraitButton,
            &headerEdit,
            &percentEdit,
            &columnEdit,
            &footerEdit,
            &borderItem,
            &borderCheck,
            &columnStat,
            &headerStat,
            &footerStat,
            &percentStat,
            &laserLister,
            NULL};              /* terminate the list with a null pointer */


/* All of the following is data for the About box */

/* Pretty picture of an Apple used as an Icon Item */

char AppleIcon640[] = {0x00,0x00,0x00,0x00,0x22,0x00,0x40,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,
0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x8f,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x88,0x8f,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x88,0x88,0x8f,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x88,0x88,0xff,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0x88,0x88,0x88,0xff,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0x88,0x88,0x8f,0xff,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0x88,0x88,0xff,0xff,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xf8,0x88,0x8f,0xff,0x88,0xff,0x88,0x88,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xf8,0x88,0x88,0x88,0x8f,0xff,0x88,0x88,0x88,0x88,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x8f,0xf0,0xf0,
0x0f,0x0f,0xfe,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xef,0xff,0xf0,0xf0,
0x0f,0x0f,0xfe,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xfe,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xef,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xf6,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x6f,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xf6,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x6f,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xf6,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x6f,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xf4,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xf4,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x4f,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x4f,0xf0,0xf0,
0x0f,0x0f,0xff,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x5f,0xf0,0xf0,
0x0f,0x0f,0xff,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x5f,0xf0,0xf0,
0x0f,0x0f,0xff,0xf5,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xf1,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x1f,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xf1,0x11,0x11,0x1f,0xff,0x11,0x11,0x11,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0x11,0x11,0xff,0xff,0xf1,0x11,0x1f,0xff,0xff,0xf0,0xf0,
0x0f,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xf0,
0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

Pointer AppleIconPtr = AppleIcon640;

/* LongStatText2 string. Red man says "Cryptic markings are:            */
/*          \1J\1\0         -> Turn on center justification             */
/*          \S\014\0        -> Choose Shadow and underlining            */
/*          Lister          -> Actually Printed                         */
/*          \S\0\0          -> Back to plain text                       */
/*          \r              -> embedded carriage return ok in TextBox2  */
/*          v1.0            -> Printed centered and normal              */
/* everything else is explained above.                                  */

char AboutStr[] = "\1J\1\0\1S\014\0\
Lister\1S\0\0\r\
v1.0\r\
\r\
by: Keith Rollin\r\
June 27, 1988";

ItemTemplate okButton =  {
            ok,
            50,12,65,68,
            buttonItem,
            "\pOK",
            0,
            0,
            NULL};

ItemTemplate aboutText =  {
            3,
            10,90,60,250,
            longStatText2+itemDisable,
            AboutStr,
            sizeof(AboutStr)-1,
            0,
            NULL};

ItemTemplate appleIcon =  {
            4,
            5,8,0,0,
            iconItem+itemDisable,
            (Pointer) &AppleIconPtr,
            0,
            0,
            NULL};

DialogTemplate AboutDialog = {
            50,190,120,450,
            true,
            0,
            &okButton,
            &aboutText,
            &appleIcon,
            NULL};


/* Dialog and item templates for the "Now Printing..." Dialog box */

char NowPrintingStr[] =
    "\1J\1\0Now printing your document";
char CancelPrintingStr[] =
    "\1J\1\0To cancel printing, hold down the \021 key and press period (.)";

ItemTemplate NowPrinting =  {
            10,
            5,10,15,430,
            longStatText2+itemDisable,
            NowPrintingStr,
            sizeof(NowPrintingStr)-1,
            0,
            NULL};

ItemTemplate CmdDotToCancel =  {
            11,
            25,10,35,430,
            longStatText2+itemDisable,
            CancelPrintingStr,
            sizeof(CancelPrintingStr)-1,
            0,
            NULL};

DialogTemplate NowPrintingDialog = {
            90,100,130,540,
            true,
            0,
            &CmdDotToCancel,
            &NowPrinting,
            NULL};


/* Oooh! Look! Something new! This is a structure used in defining a    */
/* special user item. I have a box that appears on the screen that      */
/* represents the borders that are printed. Clicking on the lines of    */
/* box turn certain borders on and off. The following array of the      */
/* following structure defines the location and status of the borders.  */

typedef struct BorderLine {
        boolean used;   /* defines if the border is to be used or not   */
        Rect    line;   /* A small rect that is used to draw and detect */
                        /* clicks on the lines representing borders.    */
        } BorderLine;

BorderLine myBorders[9] = {
        true, 100, 175, 154, 425,   /* surrounds entire box */
        true, 100, 175, 102, 425,   /* top line             */
        true, 105, 175, 107, 425,   /* under header         */
        false, 147, 175, 149, 425,  /* above footer         */
        true, 152, 175, 154, 425,   /* bottom line          */
        true, 100, 175, 154, 177,   /* left line            */
        true, 100, 299, 154, 301,   /* center line          */
        true, 100, 423, 154, 425};  /* right line           */

/* This pattern is used to show disabled borders */

Pattern greyPat  = {0xCC,0xCC,
                    0x33,0x33,
                    0xCC,0xCC,
                    0x33,0x33,
                    0xCC,0xCC,
                    0x33,0x33,
                    0xCC,0xCC,
                    0x33,0x33,
                    0xCC,0xCC,
                    0x33,0x33,
                    0xCC,0xCC,
                    0x33,0x33,
                    0xCC,0xCC,
                    0x33,0x33,
                    0xCC,0xCC,
                    0x33,0x33};


#include "lister2.c"
#include "lister3.c"
